package org.lee.springcloud.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

/**
 * @author jackielee
 * @version 1.0
 * @description GateWayApplication
 * @date 2021/3/15
 */
@SpringBootApplication
public class GateWayApplication {
  public static void main(String[] args) {
    SpringApplication.run(GateWayApplication.class, args);
  }

  /**
   * 通过@Bean配置一个/about路径
   *
   * @param builder
   * @return
   */
  @Bean
  public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
    return builder
        .routes()
        .route("about-route", r -> r.path("/about").uri("http://www.ityouknow.com"))
        .route("consul-provider", r -> r.path("/hello").uri("http://localhost:8503"))
        .build();
  }
}
